<?php

namespace app\admin\controller\member;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\admin\model\UM as UM;
use app\admin\service\MemberInvitedService;
use think\APP;
use think\Request as Request;

/**
 * MemberInvited 控制器
 * Class MemberInvited
 * @package app\admin\controller\member;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\admin\validate\member\MemberInvited
 */
class MemberInvited
{
    // 请求参数
    private Request $request;

    // service
    private MemberInvitedService $service;

    public function __construct(Request $request, MemberInvitedService $memberInvitedService)
    {
        $this->request = $request;
        $this->service = $memberInvitedService;
    }

    /**
     * 列表
     * @param UM|null $user
     * @return ApiResponse
     * @url /member/member_invited/index
     */
    public function index(?UM $user): ApiResponse
    {
        $request     = $this->request;

        $inviteId = $request->param('inviteId', null);
        $channel = $request->param('channel', null);
        $provinceId = $request->param('provinceId', null);
        $cityId = $request->param('cityId', null);
        $startTime = $request->param('startTime', null);
        $endTime = $request->param('endTime', null);
        $kw = $request->param('kw', null);

        $page      = $request->param('page', 1);
        $page_size = $request->param('page_size', 20);

        return ApiResponse::success($this->service->index($user, $channel, $provinceId, $cityId, $startTime, $endTime, $kw, $inviteId, $page, $page_size));
    }

}
